﻿using System.Collections.Generic;
using YasharEl.Infrastructure.ApplicationModel.Bootstrap.Extensibility;
using System.Diagnostics.Contracts;
using System;

namespace YasharEl.Infrastructure.ApplicationModel.Bootstrap.Behavior
{

    /// <summary>
    ///     Behaviors are elements that can be attached to executables.
    /// </summary>
    /// <typeparam name="TExtension">The type of the bootstrapping extension.</typeparam>
    [ContractClass(typeof(BehaviorContract<>))]
    public interface IBehavior<in TExtension> : IDescribable
        where TExtension : IBootstrappingExtension
    {
        /// <summary>
        /// Applies certain behavior upon the extensions.
        /// </summary>
        /// <param name="extensions">The extensions.</param>
        void Behave(IEnumerable<TExtension> extensions);
    }

    [ContractClassFor(typeof(IBehavior<>))]
    internal abstract class BehaviorContract<TExtension> : IBehavior<TExtension>
        where TExtension : IBootstrappingExtension
    {
        public void Behave(IEnumerable<TExtension> extensions)
        {
            Contract.Requires<ArgumentNullException>(extensions != null, "extensions could not be null.");
        }

        public string Name
        {
            get
            {
                return default(string);
            }
        }

        public string Describe()
        {
            return default(string);
        }
    }
}
